
clear all 

//define folder global here

gl Inputs "$folder\1_Inputs"
gl Intermediate "$folder\2_Intermediate"
gl Outputs "$folder\3_Outputs"

********************************************************************************

use "${Intermediate}\Combined for forloops.dta", clear

gen keeping = 1 if inlist(outcome, "lock", "move", "povr", "eshu", "home", "earn", "empl", "fute")
replace keeping = 1 if inlist(outcome, "inde", "cred", "zero", "deli", "auto", "hosp", "emer", "ment")
replace keeping = 1 if inlist(outcome, "movo", "stat", "an13", "payi", "paya", "numi", "numa")
keep if keeping==1 
drop keeping

keep if item=="obs" & spec=="ldv"

********************************************************************************
* DEFINE LOCALS THROUGH FOR LOOPS HERE
********************************************************************************
levelsof outcome, local(outcomes)
levelsof group, local(groups)
levelsof spec, local(specs)
levelsof time, local(times)
levelsof geo, local(geos)
levelsof item, local(items)

foreach outx in `outcomes' {
	local id1 = "`outx'"
	
	foreach grox in `groups' {
		local id2 = "`grox'"
		
		foreach spex in `specs' {
			local id3 = "`spex'"
			
			foreach timx in `times' {
				local id4 = "`timx'"
				
				foreach geox in `geos' {
					local id5 = "`geox'"
					
					foreach itex in `items' {
						local id6 = "`itex'"
		
					levelsof value if 	outcome=="`outx'" & ///
										group=="`grox'" & ///
										spec=="`spex'" & ///
										time=="`timx'" & ///
										geo=="`geox'" & ///
										item=="`itex'" , ///
						clean local(`id1'_`id2'_`id3'_`id4'_`id5'_`id6')
						di "`id1'_`id2'_`id3'_`id4'_`id5'_`id6'"
						
					}
				}
			}
		}
	}
}

				
********************************************************************************
********************************************************************************
**#TABLE H.15


texdoc init "${Outputs}/Supplementary data_Table_H15.tex", replace force
tex {\footnotesize \begin{tabular}{l c c c c c c c c c c c c} \hline \toprule ///
	& \multicolumn{5}{c}{\textbf{1-4 Quarters (1 Year) After Filing}} & ///
	& \multicolumn{5}{c}{\textbf{5-8 Quarters (2 Years) After Filing}} \\
	
tex \cmidrule{2-6} \cmidrule{8-12} 
tex $x & All & Cook & NY & Female & Black & & All & Cook & NY & Female & Black \\ 
tex & (1) & (2) & (3) & (4) & (5) & & (6) & (7) & (8) & (9) & (10) \\
tex \cmidrule{2-6} \cmidrule{8-12} 

tex \textbf{\underline{Housing outcomes:}} & \multicolumn{11}{l}{ }	\\
tex ~~Enforcement: 	& `lock_a_ldv_q0104_b_obs' & `lock_a_ldv_q0104_c_obs' & `lock_a_ldv_q0104_n_obs' & `lock_f_ldv_q0104_b_obs' & `lock_b_ldv_q0104_b_obs' &  ///
				& `lock_a_ldv_q0508_b_obs' & `lock_a_ldv_q0508_c_obs' & `lock_a_ldv_q0508_n_obs' & `lock_f_ldv_q0508_b_obs' & `lock_b_ldv_q0508_b_obs'  \\

tex \multicolumn{12}{l}{ } \\								
tex ~~Not at eviction address: 	& `move_a_ldv_q0104_b_obs' & `move_a_ldv_q0104_c_obs' & `move_a_ldv_q0104_n_obs' & `move_f_ldv_q0104_b_obs' & `move_b_ldv_q0104_b_obs' &  ///
								& `move_a_ldv_q0508_b_obs' & `move_a_ldv_q0508_c_obs' & `move_a_ldv_q0508_n_obs' & `move_f_ldv_q0508_b_obs' & `move_b_ldv_q0508_b_obs' \\
				
tex \multicolumn{12}{l}{ } \\									
tex ~~Neighborhood poverty rate: & `povr_a_ldv_q0104_b_obs' & `povr_a_ldv_q0104_c_obs' & `povr_a_ldv_q0104_n_obs' & `povr_f_ldv_q0104_b_obs' & `povr_b_ldv_q0104_b_obs' &  ///
					& `povr_a_ldv_q0508_b_obs' & `povr_a_ldv_q0508_c_obs' & `povr_a_ldv_q0508_n_obs' & `povr_f_ldv_q0508_b_obs' & `povr_b_ldv_q0508_b_obs' \\
					
tex \multicolumn{12}{l}{ } \\
tex ~~Emergency shelter: 	& `eshu_a_ldv_q0104_b_obs' & `eshu_a_ldv_q0104_c_obs' & `eshu_a_ldv_q0104_n_obs' & `eshu_f_ldv_q0104_b_obs' & `eshu_b_ldv_q0104_b_obs' &  ///
							& `eshu_a_ldv_q0508_b_obs' & `eshu_a_ldv_q0508_c_obs' & `eshu_a_ldv_q0508_n_obs' & `eshu_f_ldv_q0508_b_obs' & `eshu_b_ldv_q0508_b_obs' \\
				
tex \multicolumn{12}{l}{ } \\
tex ~~Any homelessness services: 	& `home_a_ldv_q0104_b_obs' & `home_a_ldv_q0104_c_obs' & `home_a_ldv_q0104_n_obs' & `home_f_ldv_q0104_b_obs' & `home_b_ldv_q0104_b_obs' & ///
									& `home_a_ldv_q0508_b_obs' & `home_a_ldv_q0508_c_obs' & `home_a_ldv_q0508_n_obs' & `home_f_ldv_q0508_b_obs' & `home_b_ldv_q0508_b_obs' \\
									
tex \multicolumn{12}{l}{ } \\
tex ~~Future eviction: 				& `fute_a_ldv_q0104_b_obs' & `fute_a_ldv_q0104_c_obs' & `fute_a_ldv_q0104_n_obs' & `fute_f_ldv_q0104_b_obs' & `fute_b_ldv_q0104_b_obs' & ///
									& `fute_a_ldv_q0508_b_obs' & `fute_a_ldv_q0508_c_obs' & `fute_a_ldv_q0508_n_obs' & `fute_f_ldv_q0508_b_obs' & `fute_b_ldv_q0508_b_obs' \\									

tex \midrule

tex \textbf{\underline{Labor market outcomes:}} & \multicolumn{11}{l}{ } \\
tex ~~Earnings: 	& `earn_a_ldv_q0104_b_obs' & `earn_a_ldv_q0104_c_obs' & `earn_a_ldv_q0104_n_obs' & `earn_f_ldv_q0104_b_obs' & `earn_b_ldv_q0104_b_obs' &  ///
					& `earn_a_ldv_q0508_b_obs' & `earn_a_ldv_q0508_c_obs' & `earn_a_ldv_q0508_n_obs' & `earn_f_ldv_q0508_b_obs' & `earn_b_ldv_q0508_b_obs' \\

tex \multicolumn{12}{l}{ } \\
tex ~~Employment: 	& `empl_a_ldv_q0104_b_obs' & `empl_a_ldv_q0104_c_obs' & `empl_a_ldv_q0104_n_obs' & `empl_f_ldv_q0104_b_obs' & `empl_b_ldv_q0104_b_obs' & ///
					& `empl_a_ldv_q0508_b_obs' & `empl_a_ldv_q0508_c_obs' & `empl_a_ldv_q0508_n_obs' & `empl_f_ldv_q0508_b_obs' & `empl_b_ldv_q0508_b_obs' \\

tex \midrule 

tex \textbf{\underline{Financial health outcomes:}}  & \multicolumn{11}{l}{ } \\
tex ~~Financial health index: 	& `inde_a_ldv_q0104_b_obs' & `inde_a_ldv_q0104_c_obs' & `inde_a_ldv_q0104_n_obs' & & `inde_b_ldv_q0104_b_obs' &  ///
								& `inde_a_ldv_q0508_b_obs' & `inde_a_ldv_q0508_c_obs' & `inde_a_ldv_q0508_n_obs' & & `inde_b_ldv_q0508_b_obs' \\
				
tex \multicolumn{12}{l}{ } \\
tex ~~Credit score: 	& `cred_a_ldv_q0104_b_obs' & `cred_a_ldv_q0104_c_obs' & `cred_a_ldv_q0104_n_obs' &   & `cred_b_ldv_q0104_b_obs' &  ///
						& `cred_a_ldv_q0508_b_obs' & `cred_a_ldv_q0508_c_obs' & `cred_a_ldv_q0508_n_obs' &   & `cred_b_ldv_q0508_b_obs' \\
				
tex \multicolumn{12}{l}{ } \\
tex ~~No open revolving account: 	& `zero_a_ldv_q0104_b_obs' & `zero_a_ldv_q0104_c_obs' & `zero_a_ldv_q0104_n_obs' & & `zero_b_ldv_q0104_b_obs' &  ///
									& `zero_a_ldv_q0508_b_obs' & `zero_a_ldv_q0508_c_obs' & `zero_a_ldv_q0508_n_obs' &  & `zero_b_ldv_q0508_b_obs' \\
				
tex \multicolumn{12}{l}{ } \\
tex ~~Total balance: collections and 	& `deli_a_ldv_q0104_b_obs' & `deli_a_ldv_q0104_c_obs' & `deli_a_ldv_q0104_n_obs' &  & `deli_b_ldv_q0104_b_obs' &  ///
									& `deli_a_ldv_q0508_b_obs' & `deli_a_ldv_q0508_c_obs' & `deli_a_ldv_q0508_n_obs' &  & `deli_b_ldv_q0508_b_obs' \\
				
tex \multicolumn{12}{l}{~~delinquencies: } \\
tex ~~Any auto loan or lease: 	& `auto_a_ldv_q0104_b_obs' & `auto_a_ldv_q0104_c_obs' & `auto_a_ldv_q0104_n_obs' & & `auto_b_ldv_q0104_b_obs' &  ///
								& `auto_a_ldv_q0508_b_obs' & `auto_a_ldv_q0508_c_obs' & `auto_a_ldv_q0508_n_obs' & & `auto_b_ldv_q0508_b_obs' \\

tex \midrule 

tex \textbf{\underline{Robustness-check outcomes:}}  & \multicolumn{11}{l}{ } \\
tex ~~Not at eviction address or unobserved: 	& `movo_a_ldv_q0104_b_obs' & `movo_a_ldv_q0104_c_obs' & `movo_a_ldv_q0104_n_obs' & `movo_f_ldv_q0104_c_obs'* & `movo_b_ldv_q0104_c_obs'* &  ///
								& `movo_a_ldv_q0508_b_obs' & `movo_a_ldv_q0508_c_obs' & `movo_a_ldv_q0508_n_obs' & `movo_f_ldv_q0508_c_obs'* & `movo_b_ldv_q0508_c_obs'* \\ 
	
tex \multicolumn{12}{l}{ } \\
tex ~~Moved out of state:	& `stat_a_ldv_q0104_b_obs' & `stat_a_ldv_q0104_c_obs' & `stat_a_ldv_q0104_n_obs' & `stat_f_ldv_q0104_c_obs'* & `stat_b_ldv_q0104_c_obs'* &  ///
							& `stat_a_ldv_q0508_b_obs' & `stat_a_ldv_q0508_c_obs' & `stat_a_ldv_q0508_n_obs' & `stat_f_ldv_q0508_c_obs'* & `stat_b_ldv_q0508_c_obs'* \\

tex \multicolumn{12}{l}{ } \\
tex ~~Earnings out of 13 States:		& `an13_a_ldv_q0104_b_obs' & `an13_a_ldv_q0104_c_obs' & `an13_a_ldv_q0104_n_obs' & `an13_f_ldv_q0104_c_obs'* & `an13_b_ldv_q0104_c_obs'* &  ///
									& `an13_a_ldv_q0508_b_obs' & `an13_a_ldv_q0508_c_obs' & `an13_a_ldv_q0508_n_obs' & `an13_f_ldv_q0508_c_obs'* & `an13_b_ldv_q0508_c_obs'* \\

tex \midrule 

tex \textbf{\underline{Payday outcomes:}}  & \multicolumn{11}{l}{ } \\					
																
tex ~~Any payday inquiry ($\times 100$):	& `payi_a_ldv_q0104_b_obs' & `payi_a_ldv_q0104_c_obs' & `payi_a_ldv_q0104_n_obs' & `payi_f_ldv_q0104_c_obs'* &  &  ///
										& `payi_a_ldv_q0508_b_obs' & `payi_a_ldv_q0508_c_obs' & `payi_a_ldv_q0508_n_obs' & `payi_f_ldv_q0508_c_obs'* &  \\

tex \multicolumn{12}{l}{ } \\									
tex ~~Number of payday inquiries:			& `numi_a_ldv_q0104_b_obs' & `numi_a_ldv_q0104_c_obs' & `numi_a_ldv_q0104_n_obs' & `numi_f_ldv_q0104_c_obs'* &  &  ///
										& `numi_a_ldv_q0508_b_obs' & `numi_a_ldv_q0508_c_obs' & `numi_a_ldv_q0508_n_obs' & `numi_f_ldv_q0508_c_obs'* &  \\

tex \multicolumn{12}{l}{ } \\									
tex ~~Any payday loan ($\times 100$):	& `paya_a_ldv_q0104_b_obs' & `paya_a_ldv_q0104_c_obs' & `paya_a_ldv_q0104_n_obs' & `paya_f_ldv_q0104_c_obs'* &  &  ///
										& `paya_a_ldv_q0508_b_obs' & `paya_a_ldv_q0508_c_obs' & `paya_a_ldv_q0508_n_obs' & `paya_f_ldv_q0508_c_obs'* &  \\
										
tex \multicolumn{12}{l}{ } \\									
tex ~~Number of payday loans: 				& `numa_a_ldv_q0104_b_obs' & `numa_a_ldv_q0104_c_obs' & `numa_a_ldv_q0104_n_obs' & `numa_f_ldv_q0104_c_obs'* &  &  ///
										& `numa_a_ldv_q0508_b_obs' & `numa_a_ldv_q0508_c_obs' & `numa_a_ldv_q0508_n_obs' & `numa_f_ldv_q0508_c_obs'* &  \\

										
tex \bottomrule \\
tex	\end{tabular} }
texdoc close



********************************************************************************
********************************************************************************
**# TABLE H.16


texdoc init "${Outputs}/Supplementary data_Table_H16.tex", replace force
tex {\footnotesize \begin{tabular}{l c c c c c c c c c c c c} \hline \toprule ///
	& \multicolumn{5}{c}{\textbf{9-16 Quarters (3-4 Years) After Filing}} & ///
	& \multicolumn{5}{c}{\textbf{17-24 Quarters (5-6 Years) After Filing}} \\
	
tex \cmidrule{2-6} \cmidrule{8-12} 
tex $x & All & Cook & NY & Female & Black & & All & Cook & NY & Female & Black \\
tex & (1) & (2) & (3) & (4) & (5) & & (6) & (7) & (8) & (9) & (10) \\ 
tex \cmidrule{2-6} \cmidrule{8-12} 

tex \textbf{\underline{Housing outcomes:}} & \multicolumn{11}{l}{ }	\\
tex ~~Not at eviction address: 	& `move_a_ldv_q0916_b_obs' & `move_a_ldv_q0916_c_obs' & `move_a_ldv_q0916_n_obs' & `move_f_ldv_q0916_b_obs' & `move_b_ldv_q0916_b_obs' &  ///
								& `move_a_ldv_q1724_b_obs' & `move_a_ldv_q1724_c_obs' & `move_a_ldv_q1724_n_obs' & `move_f_ldv_q1724_b_obs' & `move_b_ldv_q1724_b_obs' \\

tex \multicolumn{12}{l}{ } \\								
tex ~~Neighborhood poverty rate: 	& `povr_a_ldv_q0916_b_obs' & `povr_a_ldv_q0916_c_obs' & `povr_a_ldv_q0916_n_obs' & `povr_f_ldv_q0916_b_obs' & `povr_b_ldv_q0916_b_obs' &  ///
								& `povr_a_ldv_q1724_b_obs' & `povr_a_ldv_q1724_c_obs' & `povr_a_ldv_q1724_n_obs' & `povr_f_ldv_q1724_b_obs' & `povr_b_ldv_q1724_b_obs' \\								
								
tex \multicolumn{12}{l}{ } \\
tex ~~Emergency shelter: 	& `eshu_a_ldv_q0916_b_obs' & `eshu_a_ldv_q0916_c_obs' & `eshu_a_ldv_q0916_n_obs' & `eshu_f_ldv_q0916_b_obs' & `eshu_b_ldv_q0916_b_obs' &  ///
							& `eshu_a_ldv_q1724_b_obs' & `eshu_a_ldv_q1724_c_obs' & `eshu_a_ldv_q1724_n_obs' & `eshu_f_ldv_q1724_b_obs' & `eshu_b_ldv_q1724_b_obs' \\
				
tex \multicolumn{12}{l}{ } \\
tex ~~Any homelessness services: 	& `home_a_ldv_q0916_b_obs' & `home_a_ldv_q0916_c_obs' & `home_a_ldv_q0916_n_obs' & `home_f_ldv_q0916_b_obs' & `home_b_ldv_q0916_b_obs' & ///
									& `home_a_ldv_q1724_b_obs' & `home_a_ldv_q1724_c_obs' & `home_a_ldv_q1724_n_obs' & `home_f_ldv_q1724_b_obs' & `home_b_ldv_q1724_b_obs' \\
tex \midrule

tex \textbf{\underline{Labor market outcomes:}} & \multicolumn{11}{l}{ } \\
tex ~~Earnings: 	& `earn_a_ldv_q0916_b_obs' & `earn_a_ldv_q0916_c_obs' & `earn_a_ldv_q0916_n_obs' & `earn_f_ldv_q0916_b_obs' & `earn_b_ldv_q0916_b_obs' &  ///
					& `earn_a_ldv_q1724_b_obs' & `earn_a_ldv_q1724_c_obs' & `earn_a_ldv_q1724_n_obs' & `earn_f_ldv_q1724_b_obs' & `earn_b_ldv_q1724_b_obs' \\

tex \multicolumn{12}{l}{ } \\
tex ~~Employment: 	& `empl_a_ldv_q0916_b_obs' & `empl_a_ldv_q0916_c_obs' & `empl_a_ldv_q0916_n_obs' & `empl_f_ldv_q0916_b_obs' & `empl_b_ldv_q0916_b_obs' & ///
					& `empl_a_ldv_q1724_b_obs' & `empl_a_ldv_q1724_c_obs' & `empl_a_ldv_q1724_n_obs' & `empl_f_ldv_q1724_b_obs' & `empl_b_ldv_q1724_b_obs' \\

tex \midrule 

tex \textbf{\underline{Financial distress outcomes:}}  & \multicolumn{11}{l}{ } \\
tex ~~Financial health index: 	& `inde_a_ldv_q0916_b_obs' & `inde_a_ldv_q0916_c_obs' & `inde_a_ldv_q0916_n_obs' &   & `inde_b_ldv_q0916_b_obs' &  ///
								& `inde_a_ldv_q1724_b_obs' & `inde_a_ldv_q1724_c_obs' & `inde_a_ldv_q1724_n_obs' &   & `inde_b_ldv_q1724_b_obs' \\
				
tex \multicolumn{12}{l}{ } \\
tex ~~Credit score: 	& `cred_a_ldv_q0916_b_obs' & `cred_a_ldv_q0916_c_obs' & `cred_a_ldv_q0916_n_obs' &   & `cred_b_ldv_q0916_b_obs' &  ///
						& `cred_a_ldv_q1724_b_obs' & `cred_a_ldv_q1724_c_obs' & `cred_a_ldv_q1724_n_obs' &   & `cred_b_ldv_q1724_b_obs' \\
				
tex \multicolumn{12}{l}{ } \\
tex ~~No open revolving account: 	& `zero_a_ldv_q0916_b_obs' & `zero_a_ldv_q0916_c_obs' & `zero_a_ldv_q0916_n_obs' & & `zero_b_ldv_q0916_b_obs' &  ///
									& `zero_a_ldv_q1724_b_obs' & `zero_a_ldv_q1724_c_obs' & `zero_a_ldv_q1724_n_obs' & & `zero_b_ldv_q1724_b_obs' \\
				
tex \multicolumn{12}{l}{ } \\
tex ~~Total balance: collections and 	& `deli_a_ldv_q0916_b_obs' & `deli_a_ldv_q0916_c_obs' & `deli_a_ldv_q0916_n_obs' & & `deli_b_ldv_q0916_b_obs' &  ///
									& `deli_a_ldv_q1724_b_obs' & `deli_a_ldv_q1724_c_obs' & `deli_a_ldv_q1724_n_obs' &  & `deli_b_ldv_q1724_b_obs' \\
				
tex \multicolumn{12}{l}{~~delinquencies: } \\
tex ~~Any auto loan or lease: 	& `auto_a_ldv_q0916_b_obs' & `auto_a_ldv_q0916_c_obs' & `auto_a_ldv_q0916_n_obs' & & `auto_b_ldv_q0916_b_obs' &  ///
								& `auto_a_ldv_q1724_b_obs' & `auto_a_ldv_q1724_c_obs' & `auto_a_ldv_q1724_n_obs' & & `auto_b_ldv_q1724_b_obs' \\
										
tex \bottomrule \\
tex	\end{tabular} }
texdoc close
